package com.example.seigvp.utils;

import com.example.seigvp.pojo.Mail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @author admin
 */
@Component
public class MailUtil {

    @Autowired
    private JavaMailSender javaMailSender;//注入QQ发送邮件的bean

    public void sendSimpleMail(Mail mail) {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(mail.getSendername());
        simpleMailMessage.setTo(mail.getRecipient());
        //设置抄送邮箱
        //simpleMailMessage.setCc(cc);
        simpleMailMessage.setSubject(mail.getSubject());
        simpleMailMessage.setText(mail.getContent());
        javaMailSender.send(simpleMailMessage);
    }
}
